from .core import Builder, Namespace


class Target(Builder):
    BACKEND_PARAM = None
    
    def __init__(self, filename, **params):
        self.filename = filename
        self.params = params
        self.backend = None
    
    def get_output_name(self, node):
        locals = self.params
        self.params = Namespace(node.params)
        for k, v in self.params.itervalue():
            params[k] = v
        self.backend = self.params[self.BACKEND_PARAM]
        return "%s.%s" % (node.basename, self.backend.output_ext)
    
    def build(self, node):
        self.backend


class Executable(Target):
    BACKEND_PARAM = "unit_linker"

class Library(Target):
    BACKEND_PARAM = "unit_archiver"

class SharedLib(Target):
    BACKEND_PARAM = "unit_linker"





